<%@page import="com.kaishengit.pms.entity.Employee"%>
<%@page import="com.kaishengit.pms.util.DateUtil"%>
<%@page import="com.kaishengit.pms.util.PKUtil"%>
<%@page import="com.kaishengit.pms.entity.Idea"%>
<%@page import="com.kaishengit.pms.util.TimeNoteUtil"%>
<%@page import="com.kaishengit.pms.entity.IdeaComment"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML>
<html lang="zh-CN">
<style type="text/css">
		body{
			background-image:url(img/bb.jpg);
			background-repeat:repeat-x;
		}
	</style>
<head>
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body class="body">
	<%@ include file="include/main-top.jsp" %>
	<div class="container">
	  <div class="row">
		<jsp:include page="include/left.jsp">
			<jsp:param value="idea" name="tag"/>
		</jsp:include>
		<div class="span9">
			
			<ul style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:15px" class="breadcrumb">
				<li class="active">
					<a href="idea.jspx?m=jump2idea&projectid=${ep.project.id }"><i class="icon-fire"></i>想法</a>&gt;${idea.title }
				</li>
			</ul>
			<div class="wall">
				  <div class="page-header">
				  <%
				  	Idea idea = (Idea)request.getAttribute("idea");
				  	Employee e = (Employee)session.getAttribute("session_em");
				   %>
					<h3>${idea.title }&nbsp;&nbsp;<small><%=TimeNoteUtil.getTime(idea.getCreatetime()) %></small></h3>
				  </div>
				  <p>${idea.content }</p>
				  <div class="line">
					评论
				  </div>
				  <!-- action="idea.jspx?m=ideacomment&ideaid=${idea.id }"  -->
				  <form action="javascript:;"  method="post">
					<textarea rows="5" class="span8" id="ideacomment" name="ideacomment"></textarea>
					<br>
					<button id="ideabtn" type="submit" class="btn btn-info">发布</button>
				  </form>
				  <div id="commentblock"></div>
				  <%
				  	List<IdeaComment> ideaCommentList = (List<IdeaComment>)session.getAttribute("ideaCommentList");
				  	for(IdeaComment ic : ideaCommentList){
				   %>
				   
					 <blockquote id="block">
					  <%=ic.getContent() %>
					  <small id="small">
					  	<%=ic.getEmployee().getUsername()  %>
						<%=TimeNoteUtil.getTime(ic.getCreatetime()) %>
					    <a rel="<%=ic.getId() %>" title="删除" href="javascript:;" onclick=delComment(this)><i class="icon-trash"></i></a>
					  </small>
					</blockquote>
					
				  <%} %>
				  
				<ul class="pager">
					<li class="previous" ><a style="background-color:#59B059;color:#fff;" href="idea.jspx?m=jump2idea&projectid=${ep.project.id }">← 返回资料列表</a></li>
				</ul>
			</div>
		</div>
	  </div>
	</div>
</body>
	<script type="text/javascript">
	
		function delComment(obj){
			
			if(confirm("你确定要删除此评论吗？")){
				var id = $(obj).attr("rel");
				var del = $(obj).parent().parent();
				del.remove();
				
				$.get("idea.jspx?m=delComment&id="+id);
			}
						
		};
		$(document).ready(function(){

			$('#ideabtn').click(function(){
				
				var content = $('#ideacomment').val();
				$.post("idea.jspx?m=ideacomment&ideacomment="+content+"&ideaid=<%=idea.getId()%>",function(json){
				
					//新添加的想法评论中,把servlet中得到的id,用json传回来,然后赋给刚添加的评论
					
					//先把想法在用ajax在页面中显示
					
					var i = $("<i>").attr("class","icon-trash");
					var a = $("<a>").attr("rel",json).attr("onclick","delComment(this)").attr("title","删除").attr("href","javascript:;");
					var small = $("<small><%=e.getUsername()%><%=TimeNoteUtil.getTime(DateUtil.getNow()) %></small>");
					var bq = $("<blockquote>").text(content);
					
					$('#commentblock').append(bq.append(small.append(a.append(i))));
					
					//$('#commentblock').append($("<blockquote>"+content+"</blockquote>").append($("<small><%=e.getUsername()%><%=TimeNoteUtil.getTime(DateUtil.getNow()) %></small>").append($("<a>").attr("title","删除").attr("href","javascript:;").append($("<i>").attr("class","icon-trash")))));
				});
				
			});
		});
	
	
	</script>








</html>